package cn.jtfadmin.core.modules.quartz.enums;


import cn.jtfadmin.base.dict.annotations.Dict;
import cn.jtfadmin.base.dict.annotations.DictItem;
import org.quartz.CronTrigger;

@Dict("定时任务过期操作")
public enum MisfireInstructionActionEnum {

    @DictItem("不处理")
    DO_NOTHING(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING),

    @DictItem("立即执行")
    FIRE_NOW(CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW),

    @DictItem("忽略过期，按照未过期执行")
    IGNORE_MISFIRE_POLICY(CronTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY);


    private Integer misfireInstructionAction;

    public Integer getMisfireInstructionAction() {
        return misfireInstructionAction;
    }

    private MisfireInstructionActionEnum(Integer misfireInstructionAction) {
        this.misfireInstructionAction = misfireInstructionAction;
    }

    public static MisfireInstructionActionEnum getInstance(int cronMisfireInstruction) {
        MisfireInstructionActionEnum[] values = MisfireInstructionActionEnum.values();
        for (MisfireInstructionActionEnum value : values) {
            if (cronMisfireInstruction == value.getMisfireInstructionAction()) {
                return value;
            }
        }
        return null;
    }


}
